package com.ddwl.common.feign.api;

import com.ddwl.schema.bo.base.PageBo;
import com.ddwl.schema.bo.shop.DistributionFeeBo;
import com.ddwl.schema.bo.shop.QueryShopBo;
import com.ddwl.schema.vo.base.PageVo;
import com.ddwl.schema.vo.base.RestVo;
import com.ddwl.schema.vo.shop.DistributionFeeVo;
import com.ddwl.schema.vo.shop.ShopAccountVo;
import com.ddwl.schema.vo.shop.ShopStaffVo;
import com.ddwl.schema.vo.shop.ShopVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @Author hemiaojun
 * @Date 2020/12/1 9:22
 */
@FeignClient(name = "ddwl-shop" ,path = "/shop")
public interface ShopApi {

    /**
     * 根据用户id获取店铺信息
     * @param userId
     * @return
     */
    @GetMapping("/shop/getShopByUserId/{userId}")
    RestVo<ShopVo> getShopByUserId(@PathVariable String userId);
    /**
     * 分页查询门店
     * @param pageBo
     * @return
     */
    @PostMapping("/shop/getShopPageForApi")
    RestVo<PageVo<ShopVo>> getShopPageForApi(@Valid @RequestBody PageBo<QueryShopBo> pageBo);

    /**
     * 查询门店List
     * @param pageBo
     * @return
     */
    @PostMapping("/shop/getShops")
    RestVo<List<ShopVo>> getShops(@RequestBody QueryShopBo pageBo);

    /**
     * 查询门店详情包括分类信息
     * @param id
     * @return
     */
    @GetMapping("/shop/getShopForApi/{id}")
    RestVo<ShopVo> getShopForApi(@PathVariable String id);

    /**
     * 查询门店
     * @param id
     * @return
     */
    @GetMapping("/shop/getShopById")
    RestVo<ShopVo> getShopById(@RequestParam String id);

    /**
     * 查询默认门店
     * @return
     */
    @GetMapping("/shop/getDefaultShopForApi")
    RestVo<ShopVo> getDefaultShopForApi();

    /**
     * 根据手机号码查询门店信息
     * @param mobile
     * @return
     */
    @GetMapping("/shop/getUserShopByMobile")
    RestVo<ShopAccountVo> getUserShopByMobile(@RequestParam("mobile") String mobile);
    /**
     * 根据店铺id列表查询店铺列表
     * @param shopIds
     * @return
     */
    @PostMapping("/shop/getShopListByIds")
    RestVo<List<ShopVo>> getShopListByIds(@RequestBody Collection<String> shopIds);

    /**
     * 根据用户id获取简单店铺信息
     * @param userId
     * @return
     */
    @GetMapping("/shop/getSimpleShopByUserId/{userId}")
    RestVo<ShopVo> getSimpleShopByUserId(@PathVariable String userId);

    /**
     * 批量用户id获取简单店铺信息
     * @param userIds
     * @return
     */
    @PostMapping("/shop/getSimpleShopByUserIds")
    RestVo<List<ShopVo>> getSimpleShopByUserIds(@RequestBody List<String> userIds);

    /**
     * 查询门店
     * @param shopId
     * @param openId
     * @return
     */
    @PostMapping("/shop/queryShopByOpenIdApi")
    @ApiOperation("查询门店")
    RestVo<ShopVo> queryShopByOpenIdApi(@RequestParam String openId, @RequestParam String shopId);

    /**
     * 根据用户id和店铺id判断用户是否该店铺的管理员
     * @param userId
     * @param shopId
     * @return
     */
    @GetMapping("/shop/judgeUserHasShop")
    @ApiOperation("根据用户id和店铺id判断用户是否该店铺的管理员,如果是就返回该店铺")
    RestVo<ShopVo> judgeUserHasShop(@RequestParam("userId") String userId,@RequestParam(value = "shopId") String shopId);

    /**
     * 根据用户id查询用户管理的店铺
     * @param userId
     * @return
     */
    @GetMapping("/shopStaff/shopListForApi")
    @ApiOperation("根据用户id查询用户管理的店铺")
    RestVo<List<ShopStaffVo>> shopListForApi(@RequestParam("userId")String userId);

    /**
     * 校验是否授权操作
     * @param memberShopId
     * @param shopId
     * @return
     */
    @PostMapping("shopMember/checkMemberShop")
    @ApiOperation("校验是否授权操作")
    RestVo<ShopVo> checkMemberShop(@RequestParam String shopId,@RequestParam String memberShopId);

    /**
     * 配送费计算（订单校验）
     * @param boList
     * @return
     */
    @PostMapping("/distribution/fee")
    @ApiOperation("配送费计算（订单校验）")
    RestVo<Map<String, DistributionFeeVo>> fee(@Valid @RequestBody List<DistributionFeeBo> boList);
}
